package com.skjanyou.applicationcase.controller;

import java.util.List;

import com.skjanyou.annotation.api.Web.ResponseBody;
import com.skjanyou.annotation.api.enumclass.ResponseType;
import com.skjanyou.applicationcase.bean.Menu;
import com.skjanyou.applicationcase.service.MenuService;
import com.skjanyou.mvc.anno.Mvc.Autowired;
import com.skjanyou.mvc.anno.Mvc.Controller;
import com.skjanyou.mvc.anno.Mvc.HttpParameter;
import com.skjanyou.mvc.anno.Mvc.Mapping;

@Controller("/menu")
public class CaseController {
	@Autowired
	private MenuService menuService;
	
	@Mapping("/home")
	@ResponseBody( type = ResponseType.HTML )
	public String helloWorld(  ){
		return "<html>  <head>    <title>      mvc Server    </title>  </head>  <body>    <h1>你好!</h1>  </body></html>";
	}	
	
	@Mapping("/query")
	@ResponseBody( type = ResponseType.JSON )
	public List<Menu> selectUserMenuList( @HttpParameter("user_id") String user_id ){
		return menuService.selectUserMenuList(user_id);
	}	
	
	@Mapping("/insert")
	@ResponseBody( type = ResponseType.JSON )
	public String insertMenu( ){
		Menu m = new Menu();
		m.setMenu_id("2");m.setMenu_name("20990808");m.setUser_id("1");
		menuService.insertMenu(m);
		return "success";
	}		
}
